#ifndef __JOYSTICK_H__
#define __JOYSTICK_H__

#pragma once

using namespace System;

namespace SharpSDL
{	
	namespace ManagedSDL
	{
		typedef struct _SDL_Joystick JoystickDevice;

		public ref class Joystick
		{
		public:
			enum class JoystickStatus
			{
				Opened = 0,
				Closed = 1
			};
			enum class JoystickEvent
			{
				Enabled,
				Disabled
			};
			enum class HatStatus
			{
				Centered = SDL_HAT_CENTERED,
				Up = SDL_HAT_UP,
				Down = SDL_HAT_DOWN,
				Left = SDL_HAT_LEFT,
				Right = SDL_HAT_RIGHT,
				RightUp = SDL_HAT_RIGHT | SDL_HAT_UP,
				RightDown = SDL_HAT_RIGHT | SDL_HAT_DOWN,
				LeftUp = SDL_HAT_LEFT | SDL_HAT_UP,
				LeftDown = SDL_HAT_LEFT | SDL_HAT_DOWN
			};
			enum class ButtonStatus
			{
				ButtonUP = 0,
				ButtonDOWN = 1,
				ButtonError = -1
			};
			static int JoystickNum(void);
			static void SetJoystickEvent(JoystickEvent);
			static JoystickEvent GetJoystickEvent(void);
			static void UpdateJoystick(void);
			Joystick(int);
			~Joystick(void);
			void Open(int);
			void Close(void);
			System::String ^GetJoystickName(void);
			int GetJoystickIndex(void);
			int GetHatsNumber(void);
			int GetButtonsNumber(void);
			int GetTrackBallsNumber(void);
			int GetAxisNumber(void);
			int GetAxeStatus(int);
			HatStatus GetHatStatus(int);
			ButtonStatus GetButtonStatus(int);
			JoystickStatus GetJoystickStatus();
		private:
			JoystickDevice *CurrentJoystick;
			int JoystickIndex;
			JoystickStatus Status;
			int Axis, Buttons, TrackBalls, Hats;
		};
	}
}

#endif
